﻿using System;
using System.Web.Security;
using System.Web.UI.WebControls;
using visinia.SmartEngine;

public partial class Signup : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        visiniaLogo.ImageUrl = WebRoots.GetResourcesRoot + "Logos/visiniaMedium.png";
    }

    protected void CreateUserWizard1_CreatingUser(object sender, LoginCancelEventArgs e)
    {
        // if user already exist then just cancel 
        MembershipUser userExist = Membership.Provider.GetUser(visiniaCreateUserWizard.UserName, false);
        if (userExist != null)
        {
            if (string.Compare(userExist.UserName, visiniaCreateUserWizard.UserName, true) == 0)
            {
                visiniaError.Text = "User Name Already Registered";
                visiniaError.Visible = true;
                e.Cancel = true;
            }
        }
    }
    protected void visiniaCreateUserWizard_CreatedUser(object sender, EventArgs e)
    {
        Roles.AddUserToRole(visiniaCreateUserWizard.UserName, "Guest");
    }
}
